<p id="notice"><%= notice %></p>

<h1><%= @product.codename %></h1>

<% if @product.current_state %>
  <h2>Current state: <%= @product.current_state.class %></h2>

  
  <% if @product.current_state.class.next_states %>
    <h2>Possible actions:</h2>
    <ul>
      <% @product.current_state.class.next_states.each do |state| %>
        <li><%= link_to state.to_s, "/" + state.to_s.downcase.pluralize + "/new?product_id=" + @product.id.to_s %></li>
      <% end %>
    </ul>
  <% else %>
    <h2>No possible actions</h2>
  <% end %>

<% else %>
  <p><%= link_to 'Assembly', new_product_assembly_path + "?product_id=" + @product.id.to_s %></p>
<% end %>

<% if @product.transitions %>
  <h2>History</h2>
  <ol>
    <% @product.transitions.each do |transition| %>
      <li><%=transition.created_at%> - <%= link_to transition.to_class, [@product,transition.to] %></li>
    <% end %>
  </ol>
<% end %>

<%= link_to 'Edit', edit_product_path(@product) %> |
<%= link_to 'Back', products_path %>
